home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / adatutor / csparts / clibody.src < prev    next >
Text File  |  1996-01-30  |  43KB  |  1,197 lines

  1. --::::::::::
  2. --clibody.inc
  3. --::::::::::
  4. -- This include file
  5. clibody.inc
  6. -- Select one of these package
  7. -- bodies, depending on your compiler
  8. --    CLIALUNX - Alsys Ada for UNIX
  9. --    CLIALDOS - Alsys Ada for DOS
  10. --    CLICAIS  - CAIS
  11. --    CLIINTGR - Integr/Ada
  12. --    CLIMERDN - Meridian Ada
  13. --    CLIVERDX - Verdix Ada
  14. --    CLIVMS   - DEC Ada
  15. --    CLIGENRL - Any other compiler
  16. clialunx.ada
  17. clialdos.ada
  18. clicais.ada
  19. cligenrl.ada
  20. cliintgr.ada
  21. climerdn.ada
  22. cliverdx.ada
  23. clivms.ada
  24. --::::::::::
  25. --clialunx.ada
  26. --::::::::::
  27. -- This implementation of Package Body CLI is Alsys-specific (SUN).
  28. -- It requires the Alsys package SYSTEM_ENVIRONMENT.
  29. -- Alsys Ada, Version 3.2
  30. with TEXT_IO;
  31. with SYSTEM_ENVIRONMENT;
  32. package body CLI is
  33.  
  34.    LOCAL_ARGC : NATURAL := SYSTEM_ENVIRONMENT.ARG_COUNT;
  35.    -- Value of ARGC as stored internally
  36.    
  37.    procedure INITIALIZE (PROGRAM_NAME        : in STRING;
  38.                          COMMAND_LINE_PROMPT : in STRING) is
  39.       
  40.       --========================= PDL ===========================
  41.       --|ABSTRACT:
  42.       --|    INITIALIZE performs necessary initializations.
  43.       --|DESIGN DESCRIPTION:
  44.       --|    No initialization needed
  45.       --=========================================================
  46.       
  47.    begin
  48.       null;
  49.    end INITIALIZE;
  50.    
  51.    function ARGC return NATURAL is
  52.       
  53.       --========================= PDL ===========================
  54.       --|ABSTRACT:
  55.       --|    ARGC returns the argument count.
  56.       --|DESIGN DESCRIPTION:
  57.       --|    Return LOCAL_ARGC
  58.       --=========================================================
  59.       
  60.    begin
  61.       return LOCAL_ARGC;
  62.    end ARGC;
  63.  
  64.    function ARGV (INDEX : in NATURAL) return STRING is
  65.       
  66.       --========================= PDL ===========================
  67.       --|ABSTRACT:
  68.       --|    ARGV returns the indicated argument string.
  69.       --|DESIGN DESCRIPTION:
  70.       --|    If INDEX is out of range, raise INVALID_INDEX
  71.       --|    Return GET_FROM_LIST(INDEX)
  72.       --=========================================================
  73.       
  74.    begin
  75.       if INDEX >= LOCAL_ARGC then
  76.          raise INVALID_INDEX;
  77.       end if;
  78.       return SYSTEM_ENVIRONMENT.ARG_VALUE (INDEX);
  79.    exception
  80.       when INVALID_INDEX  =>
  81.          raise ;
  82.       when others    =>
  83.          raise UNEXPECTED_ERROR;
  84.    end ARGV;
  85.    
  86. end CLI;
  87. --::::::::::
  88. --clialdos.ada
  89. --::::::::::
  90. --::::::::::
  91. --clialsys.ada
  92. --::::::::::
  93. -- This implementation of Package Body CLI is Alsys-specific (SUN).
  94. -- It requires the Alsys package DOS.
  95. -- Alsys Ada, Version 5
  96. with DOS;
  97. package body CLI is
  98.  
  99.    LOCAL_ARGC : NATURAL;
  100.  
  101.    type TOKEN_SCAN_STATE is (OUTSIDE_OF_TOKEN, INSIDE_OF_TOKEN);
  102.  
  103.    function ARGC_VALUE (TOKENS : in STRING) return NATURAL is
  104.       COUNTER : NATURAL := 0;
  105.       CURRENT_STATE : TOKEN_SCAN_STATE := OUTSIDE_OF_TOKEN;
  106.    begin
  107.       for I in TOKENS'FIRST .. TOKENS'LAST loop
  108.           case CURRENT_STATE is
  109.               when OUTSIDE_OF_TOKEN =>
  110.                   if TOKENS(I) > ' ' then
  111.                       COUNTER := COUNTER + 1;
  112.                       CURRENT_STATE := INSIDE_OF_TOKEN;
  113.                   end if;
  114.               when INSIDE_OF_TOKEN =>
  115.                   if TOKENS(I) <= ' ' then
  116.                       CURRENT_STATE := OUTSIDE_OF_TOKEN;
  117.                   end if;
  118.           end case;
  119.       end loop;
  120.       return COUNTER;
  121.    end ARGC_VALUE;
  122.  
  123.    procedure INITIALIZE (PROGRAM_NAME        : in STRING;
  124.                          COMMAND_LINE_PROMPT : in STRING) is
  125.       
  126.       --========================= PDL ===========================
  127.       --|ABSTRACT:
  128.       --|    INITIALIZE performs necessary initializations.
  129.       --|DESIGN DESCRIPTION:
  130.       --|    Set the value of LOCAL_ARGC by parsing tokens.
  131.       --=========================================================
  132.       
  133.    begin
  134.       LOCAL_ARGC := ARGC_VALUE (DOS.GET_PARMS) + 1;
  135.    end INITIALIZE;
  136.    
  137.    function ARGC return NATURAL is
  138.       
  139.       --========================= PDL ===========================
  140.       --|ABSTRACT:
  141.       --|    ARGC returns the argument count.
  142.       --|DESIGN DESCRIPTION:
  143.       --|    Return LOCAL_ARGC.
  144.       --=========================================================
  145.       
  146.    begin
  147.       return LOCAL_ARGC;
  148.    end ARGC;
  149.  
  150.    function ARG_VALUE (TOKENS : in STRING; INDEX : in NATURAL)
  151.      return STRING is
  152.        FIRST, LAST, COUNTER : NATURAL;
  153.        CURRENT_STATE : TOKEN_SCAN_STATE := OUTSIDE_OF_TOKEN;
  154.    begin
  155.       FIRST := TOKENS'FIRST;
  156.       LAST := TOKENS'FIRST-1;
  157.       COUNTER := 0;
  158.       if INDEX = 0 then
  159.           return DOS.GET_PROGRAM_NAME;
  160.       else
  161.           for I in TOKENS'FIRST .. TOKENS'LAST loop
  162.               case CURRENT_STATE is
  163.                   when OUTSIDE_OF_TOKEN =>
  164.                       if TOKENS(I) > ' ' then
  165.                           COUNTER := COUNTER + 1;
  166.                           CURRENT_STATE := INSIDE_OF_TOKEN;
  167.                           if COUNTER = INDEX then
  168.                               FIRST := I;
  169.                               LAST := TOKENS'LAST;
  170.                           end if;
  171.                       end if;
  172.                   when INSIDE_OF_TOKEN =>
  173.                       if TOKENS(I) <= ' ' then
  174.                           CURRENT_STATE := OUTSIDE_OF_TOKEN;
  175.                           if COUNTER = INDEX then
  176.                               LAST := I - 1;
  177.                           end if;
  178.                       end if;
  179.               end case;
  180.           end loop;
  181.           if LAST < FIRST then
  182.             return "";
  183.           else
  184.             return TOKENS(FIRST .. LAST);
  185.           end if;
  186.       end if;
  187.    end ARG_VALUE;
  188.  
  189.    function ARGV (INDEX : in NATURAL) return STRING is
  190.       
  191.       --========================= PDL ===========================
  192.       --|ABSTRACT:
  193.       --|    ARGV returns the indicated argument string.
  194.       --|DESIGN DESCRIPTION:
  195.       --|    If INDEX is out of range, raise INVALID_INDEX
  196.       --|    Run parse and return desired token.
  197.       --=========================================================
  198.       
  199.    begin
  200.       if INDEX >= LOCAL_ARGC then
  201.          raise INVALID_INDEX;
  202.       end if;
  203.       return ARG_VALUE (DOS.GET_PARMS, INDEX);
  204.    exception
  205.       when INVALID_INDEX  =>
  206.          raise ;
  207.       when others    =>
  208.          raise UNEXPECTED_ERROR;
  209.    end ARGV;
  210.  
  211. begin -- Initialization section
  212.   INITIALIZE("", "");   
  213. end CLI;
  214. --::::::::::
  215. --clicais.ada
  216. --::::::::::
  217. -- This implementation of Package Body CLI interfaces thru a CAIS
  218. -- (CAIS = Common APSE Interface Set, where APSE = Ada Programming
  219. -- Support Environment).
  220. -- The definition of CAIS used was DoD-STD-1838, dated 9 October 1986.
  221. -- Note: THIS IS UNTESTED BUT BELIEVED TO BE CORRECT (no working CAIS
  222. --       implementation was available to test this against).
  223. with CAIS_PROCESS_DEFINITIONS;
  224. with CAIS_PROCESS_MANAGEMENT;
  225. with CAIS_LIST_MANAGEMENT;
  226. package body CLI is
  227.  
  228.    LOCAL_ARGC : NATURAL := 1;
  229.    -- Local ARGC value used internally
  230.  
  231.    package STRING_LIST is
  232.       
  233.       NUMBER_OF_STRINGS : NATURAL := 0;
  234.       
  235.       procedure ADD_TO_LIST (ITEM : in STRING);
  236.       function GET_FROM_LIST (ITEM : in NATURAL) return STRING;
  237.       
  238.    end STRING_LIST;
  239.    
  240.    package body STRING_LIST is
  241.       
  242.       type DYNAMIC_STRING_OBJECT (LENGTH : NATURAL);
  243.       type DYNAMIC_STRING is access DYNAMIC_STRING_OBJECT;
  244.       type DYNAMIC_STRING_OBJECT (LENGTH : NATURAL) is 
  245.          record
  246.             DS   : STRING (1 .. LENGTH);
  247.             NEXT : DYNAMIC_STRING;
  248.          end record;
  249.       
  250.       FIRST : DYNAMIC_STRING := null;
  251.       LAST  : DYNAMIC_STRING := null;
  252.       
  253.       procedure ADD_TO_LIST (ITEM : in STRING) is
  254.          
  255.          --========================= PDL ===========================
  256.          --|ABSTRACT:
  257.          --|    ADD_TO_LIST adds the ITEM string to the linked list
  258.          --|    of dynamic strings implemented by this package.
  259.          --|DESIGN DESCRIPTION:
  260.          --|    Create new DYNAMIC_STRING_OBJECT of the proper length
  261.          --|    Set DS field of new object to the ITEM string
  262.          --|    Set the NEXT field of the new object to NULL
  263.          --|    If FIRST pointer is null
  264.          --|      Set FIRST and LAST to point to the new object
  265.          --|    Else
  266.          --|      Set LAST.NEXT to point to the new object
  267.          --|      Set LAST to point to the new object
  268.          --|    End if
  269.          --|    Increment NUMBER_OF_STRINGS
  270.          --=========================================================
  271.          
  272.          TEMP : DYNAMIC_STRING;
  273.       begin
  274.          TEMP := new DYNAMIC_STRING_OBJECT (ITEM'LENGTH);
  275.          TEMP.DS (1 .. ITEM'LENGTH) := ITEM;
  276.          TEMP.NEXT                  := null;
  277.          if FIRST = null then
  278.             FIRST := TEMP;
  279.             LAST  := TEMP;
  280.          else
  281.             LAST.NEXT := TEMP;
  282.             LAST      := TEMP;
  283.          end if;
  284.          NUMBER_OF_STRINGS := NUMBER_OF_STRINGS + 1;
  285.       end ADD_TO_LIST;
  286.       
  287.       function GET_FROM_LIST (ITEM : in NATURAL) return STRING is
  288.          
  289.          --========================= PDL ===========================
  290.          --|ABSTRACT:
  291.          --|    GET_FROM_LIST returns the ITEM string from the linked list
  292.          --|    of dynamic strings implemented by this package.
  293.          --|DESIGN DESCRIPTION:
  294.          --|    If ITEM > 0
  295.          --|        Advance to desired item
  296.          --|    End If
  297.          --|    Return the DS field of the desired item
  298.          --=========================================================
  299.          
  300.          ROVER : DYNAMIC_STRING := FIRST;
  301.       begin
  302.          if ITEM > 0 then
  303.             for I in 1 .. ITEM loop
  304.                ROVER := ROVER.NEXT;
  305.             end loop;
  306.          end if;
  307.          return ROVER.DS;
  308.       end GET_FROM_LIST;
  309.       
  310.    end STRING_LIST;
  311.    
  312.    procedure INITIALIZE (PROGRAM_NAME        : in STRING;
  313.                          COMMAND_LINE_PROMPT : in STRING) is
  314.       
  315.       --========================= PDL ===========================
  316.       --|ABSTRACT:
  317.       --|    INITIALIZE prompts the user for the command line
  318.       --|    arguments and loads the linked list with them.
  319.       --|DESIGN DESCRIPTION:
  320.       --|    Set the first list object to PROGRAM_NAME
  321.       --|    Get the list of parameters for the process
  322.       --|    For each parameter, loop
  323.       --|        Extract the next parameter (item)
  324.       --|        Convert the parameter (item) to text
  325.       --|        Add text to the list
  326.       --|    End Loop
  327.       --|    Set LOCAL_ARGC to NUMBER_OF_STRINGS
  328.       --=========================================================
  329.       
  330.       PARAMETERS           : CAIS_PROCESS_DEFINITIONS.PARAMETER_LIST;
  331.       CURRENT_PARAMETER    : CAIS_PROCESS_DEFINITIONS.PARAMETER_LIST;
  332.       NUMBER_OF_PARAMETERS : CAIS_LIST_MANAGEMENT.LIST_SIZE;
  333.  
  334.    begin
  335.       STRING_LIST.ADD_TO_LIST(PROGRAM_NAME);
  336.       CAIS_PROCESS_MANAGEMENT.GET_PARAMETERS (PARAMETERS);
  337.       NUMBER_OF_PARAMETERS := CAIS_LIST_MANAGEMENT.NUMBER_OF_ITEMS
  338.             (PARAMETERS);
  339.       for I in 1 .. NUMBER_OF_PARAMETERS loop
  340.          CAIS_LIST_MANAGEMENT.CAIS_LIST_ITEM.EXTRACT_VALUE
  341.                (FROM_LIST     => PARAMETERS,
  342.                 ITEM_POSITION => I,
  343.                 VALUE         => CURRENT_PARAMETER);
  344.          STRING_LIST.ADD_TO_LIST
  345.                (CAIS_LIST_MANAGEMENT.TEXT_FORM(CURRENT_PARAMETER));
  346.       end loop;
  347.       LOCAL_ARGC := STRING_LIST.NUMBER_OF_STRINGS;
  348.    end INITIALIZE;
  349.    
  350.    function ARGC return NATURAL is
  351.       
  352.       --========================= PDL ===========================
  353.       --|ABSTRACT:
  354.       --|    ARGC returns the argument count.
  355.       --|DESIGN DESCRIPTION:
  356.       --|    Return LOCAL_ARGC
  357.       --=========================================================
  358.       
  359.    begin
  360.       return LOCAL_ARGC;
  361.    end ARGC;
  362.  
  363.    function ARGV (INDEX : in NATURAL) return STRING is
  364.       
  365.       --========================= PDL ===========================
  366.       --|ABSTRACT:
  367.       --|    ARGV returns the indicated argument string.
  368.       --|DESIGN DESCRIPTION:
  369.       --|    If INDEX is out of range, raise INVALID_INDEX
  370.       --|    Return GET_FROM_LIST(INDEX)
  371.       --=========================================================
  372.       
  373.    begin
  374.       if INDEX >= ARGC then
  375.          raise INVALID_INDEX;
  376.       end if;
  377.       return STRING_LIST.GET_FROM_LIST (INDEX);
  378.    exception
  379.       when INVALID_INDEX  =>
  380.          raise ;
  381.       when others    =>
  382.          raise UNEXPECTED_ERROR;
  383.    end ARGV;
  384.    
  385. end CLI;
  386. --::::::::::
  387. --cligenrl.ada
  388. --::::::::::
  389. -- This implementation of Package Body CLI is general-purpose.
  390. -- Using TEXT_IO, it prompts the user for input arguments and
  391. -- accepts these arguments via a GET_LINE call.
  392. with TEXT_IO;
  393. package body CLI is
  394.  
  395.    LOCAL_ARGC : NATURAL := 0;
  396.    
  397.    package STRING_LIST is
  398.       
  399.       NUMBER_OF_STRINGS : NATURAL := 0;
  400.       
  401.       procedure ADD_TO_LIST (ITEM : in STRING);
  402.       function GET_FROM_LIST (ITEM : in NATURAL) return STRING;
  403.       
  404.    end STRING_LIST;
  405.    
  406.    package body STRING_LIST is
  407.       
  408.       type DYNAMIC_STRING_OBJECT (LENGTH : NATURAL);
  409.       type DYNAMIC_STRING is access DYNAMIC_STRING_OBJECT;
  410.       type DYNAMIC_STRING_OBJECT (LENGTH : NATURAL) is 
  411.          record
  412.             DS   : STRING (1 .. LENGTH);
  413.             NEXT : DYNAMIC_STRING;
  414.          end record;
  415.       
  416.       FIRST : DYNAMIC_STRING := null;
  417.       LAST  : DYNAMIC_STRING := null;
  418.       
  419.       procedure ADD_TO_LIST (ITEM : in STRING) is
  420.          
  421.          --========================= PDL ===========================
  422.          --|ABSTRACT:
  423.          --|    ADD_TO_LIST adds the ITEM string to the linked list
  424.          --|    of dynamic strings implemented by this package.
  425.          --|DESIGN DESCRIPTION:
  426.          --|    Create new DYNAMIC_STRING_OBJECT of the proper length
  427.          --|    Set DS field of new object to the ITEM string
  428.          --|    Set the NEXT field of the new object to NULL
  429.          --|    If FIRST pointer is null
  430.          --|      Set FIRST and LAST to point to the new object
  431.          --|    Else
  432.          --|      Set LAST.NEXT to point to the new object
  433.          --|      Set LAST to point to the new object
  434.          --|    End if
  435.          --|    Increment NUMBER_OF_STRINGS
  436.          --=========================================================
  437.          
  438.          TEMP : DYNAMIC_STRING;
  439.       begin
  440.          TEMP := new DYNAMIC_STRING_OBJECT (ITEM'LENGTH);
  441.          TEMP.DS (1 .. ITEM'LENGTH) := ITEM;
  442.          TEMP.NEXT                  := null;
  443.          if FIRST = null then
  444.             FIRST := TEMP;
  445.             LAST  := TEMP;
  446.          else
  447.             LAST.NEXT := TEMP;
  448.             LAST      := TEMP;
  449.          end if;
  450.          NUMBER_OF_STRINGS := NUMBER_OF_STRINGS + 1;
  451.       end ADD_TO_LIST;
  452.       
  453.       function GET_FROM_LIST (ITEM : in NATURAL) return STRING is
  454.          
  455.          --========================= PDL ===========================
  456.          --|ABSTRACT:
  457.          --|    GET_FROM_LIST returns the ITEM string from the linked list
  458.          --|    of dynamic strings implemented by this package.
  459.          --|DESIGN DESCRIPTION:
  460.          --|    If ITEM > 0
  461.          --|        Advance to desired item
  462.          --|    End If
  463.          --|    Return the DS field of the desired item
  464.          --=========================================================
  465.          
  466.          ROVER : DYNAMIC_STRING := FIRST;
  467.       begin
  468.          if ITEM > 0 then
  469.             for I in 1 .. ITEM loop
  470.                ROVER := ROVER.NEXT;
  471.             end loop;
  472.          end if;
  473.          return ROVER.DS;
  474.       end GET_FROM_LIST;
  475.       
  476.    end STRING_LIST;
  477.    
  478.    procedure INITIALIZE (PROGRAM_NAME        : in STRING;
  479.                          COMMAND_LINE_PROMPT : in STRING) is
  480.       
  481.       --========================= PDL ===========================
  482.       --|ABSTRACT:
  483.       --|    INITIALIZE prompts the user for the command line
  484.       --|    arguments and loads the linked list with them.
  485.       --|DESIGN DESCRIPTION:
  486.       --|    Set CURRENT_STATE to LOOKING_FOR_TOKEN
  487.       --|    Set the first list object to PROGRAM_NAME
  488.       --|    Prompt the user with COMMAND_LINE_PROMPT and
  489.       --|      get his response
  490.       --|    Over number of characters in line, loop
  491.       --|        Case CURRENT_STATE
  492.       --|            When LOOKING_FOR_TOKEN
  493.       --|                If character is not white-space
  494.       --|                    Set CURRENT_STATE to IN_TOKEN
  495.       --|                    If character is quote (")
  496.       --|                        Set QUOTED to TRUE
  497.       --|                        Set START to the character's index + 1
  498.       --|                    Else
  499.       --|                        Set QUOTED to FALSE
  500.       --|                        Set START to the character's index
  501.       --|                    End IF
  502.       --|                End If
  503.       --|            When IN_TOKEN
  504.       --|                If QUOTED
  505.       --|                    If character is quote (")
  506.       --|                        Set STOP to the previous character's index
  507.       --|                        Add slice from START to STOP to list
  508.       --|                        Set CURRENT_STATE to LOOKING_FOR_TOKEN
  509.       --|                    End If
  510.       --|                ElsIF character is white-space
  511.       --|                    Set STOP to the previous character's index
  512.       --|                    Add slice from START to STOP to list
  513.       --|                    Set CURRENT_STATE to LOOKING_FOR_TOKEN
  514.       --|                End If
  515.       --|        End Case
  516.       --|    End Loop
  517.       --|    If CURRENT_STATE is IN_TOKEN
  518.       --|        Set STOP to the previous character's index
  519.       --|        Add slice from START to STOP to list
  520.       --|    End if
  521.       --|    Set LOCAL_ARGC to NUMBER_OF_STRINGS
  522.       --|    Output NEW_LINE (to reset column count in TEXT_IO)
  523.       --=========================================================
  524.       
  525.       ARGCOUNT      : NATURAL := 1;
  526.       INLINE        : STRING (1 .. 400);
  527.       LAST          : NATURAL;
  528.       START         : NATURAL;
  529.       STOP          : NATURAL;
  530.       QUOTED        : BOOLEAN;
  531.       type STATE is (LOOKING_FOR_TOKEN, IN_TOKEN);
  532.       CURRENT_STATE : STATE   := LOOKING_FOR_TOKEN;
  533.    begin
  534.       STRING_LIST.ADD_TO_LIST (PROGRAM_NAME);
  535.       TEXT_IO.PUT (COMMAND_LINE_PROMPT);
  536.       TEXT_IO.GET_LINE (INLINE, LAST);
  537.       for I in 1 .. LAST loop
  538.          case CURRENT_STATE is
  539.             when LOOKING_FOR_TOKEN  =>
  540.                if INLINE (I) > ' ' then
  541.                   CURRENT_STATE := IN_TOKEN;
  542.                   if INLINE (I) = '"' then
  543.                      QUOTED := TRUE;
  544.                      START  := I;
  545.                   else
  546.                      QUOTED := FALSE;
  547.                      START  := I;
  548.                   end if;
  549.                end if;
  550.             when IN_TOKEN =>
  551.                if QUOTED then
  552.                   if INLINE (I) = '"' then
  553.                      STOP          := I;
  554.                      STRING_LIST.ADD_TO_LIST (INLINE (START .. STOP));
  555.                      CURRENT_STATE := LOOKING_FOR_TOKEN;
  556.                   end if;
  557.                elsif INLINE (I) <= ' ' then
  558.                   STOP          := I - 1;
  559.                   STRING_LIST.ADD_TO_LIST (INLINE (START .. STOP));
  560.                   CURRENT_STATE := LOOKING_FOR_TOKEN;
  561.                end if;
  562.          end case;
  563.       end loop;
  564.       if CURRENT_STATE = IN_TOKEN then
  565.          STOP := LAST;
  566.          STRING_LIST.ADD_TO_LIST (INLINE (START .. STOP));
  567.       end if;
  568.       LOCAL_ARGC := STRING_LIST.NUMBER_OF_STRINGS;
  569.       TEXT_IO.NEW_LINE;
  570.    end INITIALIZE;
  571.    
  572.    function ARGC return NATURAL is
  573.       
  574.       --========================= PDL ===========================
  575.       --|ABSTRACT:
  576.       --|    ARGC returns the argument count.
  577.       --|DESIGN DESCRIPTION:
  578.       --|    Return LOCAL_ARGC
  579.       --=========================================================
  580.       
  581.    begin
  582.       return LOCAL_ARGC;
  583.    end ARGC;
  584.  
  585.    function ARGV (INDEX : in NATURAL) return STRING is
  586.       
  587.       --========================= PDL ===========================
  588.       --|ABSTRACT:
  589.       --|    ARGV returns the indicated argument string.
  590.       --|DESIGN DESCRIPTION:
  591.       --|    If INDEX is out of range, raise INVALID_INDEX
  592.       --|    Return GET_FROM_LIST(INDEX)
  593.       --=========================================================
  594.       
  595.    begin
  596.       if INDEX >= LOCAL_ARGC then
  597.          raise INVALID_INDEX;
  598.       end if;
  599.       return STRING_LIST.GET_FROM_LIST (INDEX);
  600.    exception
  601.       when INVALID_INDEX  =>
  602.          raise ;
  603.       when others    =>
  604.          raise UNEXPECTED_ERROR;
  605.    end ARGV;
  606.    
  607. end CLI;
  608. --::::::::::
  609. --cliintgr.ada
  610. --::::::::::
  611. -- This implementation of Package Body CLI is for IntegrAda.
  612. -- It has been tested under IntegrAda 4.0.1 using MSDOS 3.3.
  613. with UTIL;
  614. package body CLI is
  615.  
  616.    LOCAL_ARGC : NATURAL := 1;
  617.    -- Local ARGC value stored internally
  618.  
  619.    package STRING_LIST is
  620.       
  621.       NUMBER_OF_STRINGS : NATURAL := 0;
  622.       
  623.       procedure ADD_TO_LIST (ITEM : in STRING);
  624.       function GET_FROM_LIST (ITEM : in NATURAL) return STRING;
  625.       
  626.    end STRING_LIST;
  627.    
  628.    package body STRING_LIST is
  629.       
  630.       type DYNAMIC_STRING_OBJECT (LENGTH : NATURAL);
  631.       type DYNAMIC_STRING is access DYNAMIC_STRING_OBJECT;
  632.       type DYNAMIC_STRING_OBJECT (LENGTH : NATURAL) is 
  633.          record
  634.             DS   : STRING (1 .. LENGTH);
  635.             NEXT : DYNAMIC_STRING;
  636.          end record;
  637.       
  638.       FIRST : DYNAMIC_STRING := null;
  639.       LAST  : DYNAMIC_STRING := null;
  640.       
  641.       procedure ADD_TO_LIST (ITEM : in STRING) is
  642.          
  643.          --========================= PDL ===========================
  644.          --|ABSTRACT:
  645.          --|    ADD_TO_LIST adds the ITEM string to the linked list
  646.          --|    of dynamic strings implemented by this package.
  647.          --|DESIGN DESCRIPTION:
  648.          --|    Create new DYNAMIC_STRING_OBJECT of the proper length
  649.          --|    Set DS field of new object to the ITEM string
  650.          --|    Set the NEXT field of the new object to NULL
  651.          --|    If FIRST pointer is null
  652.          --|      Set FIRST and LAST to point to the new object
  653.          --|    Else
  654.          --|      Set LAST.NEXT to point to the new object
  655.          --|      Set LAST to point to the new object
  656.          --|    End if
  657.          --|    Increment NUMBER_OF_STRINGS
  658.          --=========================================================
  659.          
  660.          TEMP : DYNAMIC_STRING;
  661.       begin
  662.          TEMP := new DYNAMIC_STRING_OBJECT (ITEM'LENGTH);
  663.          TEMP.DS (1 .. ITEM'LENGTH) := ITEM;
  664.          TEMP.NEXT                  := null;
  665.          if FIRST = null then
  666.             FIRST := TEMP;
  667.             LAST  := TEMP;
  668.          else
  669.             LAST.NEXT := TEMP;
  670.             LAST      := TEMP;
  671.          end if;
  672.          NUMBER_OF_STRINGS := NUMBER_OF_STRINGS + 1;
  673.       end ADD_TO_LIST;
  674.       
  675.       function GET_FROM_LIST (ITEM : in NATURAL) return STRING is
  676.          
  677.          --========================= PDL ===========================
  678.          --|ABSTRACT:
  679.          --|    GET_FROM_LIST returns the ITEM string from the linked list
  680.          --|    of dynamic strings implemented by this package.
  681.          --|DESIGN DESCRIPTION:
  682.          --|    If ITEM > 0
  683.          --|        Advance to desired item
  684.          --|    End If
  685.          --|    Return the DS field of the desired item
  686.          --=========================================================
  687.          
  688.          ROVER : DYNAMIC_STRING := FIRST;
  689.       begin
  690.          if ITEM > 0 then
  691.             for I in 1 .. ITEM loop
  692.                ROVER := ROVER.NEXT;
  693.             end loop;
  694.          end if;
  695.          return ROVER.DS;
  696.       end GET_FROM_LIST;
  697.       
  698.    end STRING_LIST;
  699.    
  700.    procedure INITIALIZE (PROGRAM_NAME        : in STRING;
  701.                          COMMAND_LINE_PROMPT : in STRING) is
  702.       
  703.       --========================= PDL ===========================
  704.       --|ABSTRACT:
  705.       --|    INITIALIZE prompts the user for the command line
  706.       --|    arguments and loads the linked list with them.
  707.       --|DESIGN DESCRIPTION:
  708.       --|    Set CURRENT_STATE to LOOKING_FOR_TOKEN
  709.       --|    Set PROGRAM_NAME as first token
  710.       --|    Obtain the command line string from VAX/VMS
  711.       --|    Over number of characters in line, loop
  712.       --|        Case CURRENT_STATE
  713.       --|            When LOOKING_FOR_TOKEN
  714.       --|                If character is not white-space
  715.       --|                    Set CURRENT_STATE to IN_TOKEN
  716.       --|                    If character is quote (")
  717.       --|                        Set QUOTED to TRUE
  718.       --|                        Set START to the character's index + 1
  719.       --|                    Else
  720.       --|                        Set QUOTED to FALSE
  721.       --|                        Set START to the character's index
  722.       --|                    End IF
  723.       --|                End If
  724.       --|            When IN_TOKEN
  725.       --|                If QUOTED
  726.       --|                    If character is quote (")
  727.       --|                        Set STOP to the previous character's index
  728.       --|                        Add slice from START to STOP to list
  729.       --|                        Set CURRENT_STATE to LOOKING_FOR_TOKEN
  730.       --|                    End If
  731.       --|                ElsIF character is white-space
  732.       --|                    Set STOP to the previous character's index
  733.       --|                    Add slice from START to STOP to list
  734.       --|                    Set CURRENT_STATE to LOOKING_FOR_TOKEN
  735.       --|                End If
  736.       --|        End Case
  737.       --|    End Loop
  738.       --|    If CURRENT_STATE is IN_TOKEN
  739.       --|        Set STOP to the previous character's index
  740.       --|        Add slice from START to STOP to list
  741.       --|    End if
  742.       --|    Set LOCAL_ARGC to NUMBER_OF_STRINGS
  743.       --=========================================================
  744.       
  745.       ARGCOUNT      : NATURAL := 1;
  746.       INLINE        : UTIL.COMMAND_STRING; -- for IntegrAda
  747.       INLEN         : NATURAL;             -- for IntegrAda
  748.       START         : NATURAL;
  749.       STOP          : NATURAL;
  750.       QUOTED        : BOOLEAN;
  751.  
  752.       type STATE is (LOOKING_FOR_TOKEN, IN_TOKEN);
  753.       CURRENT_STATE : STATE   := LOOKING_FOR_TOKEN;
  754.  
  755.    begin
  756.       STRING_LIST.ADD_TO_LIST (PROGRAM_NAME);
  757.       UTIL.COMMAND_LINE (INLINE, INLEN); -- INLINE is command line
  758.       for I in 1 .. INLEN loop
  759.          case CURRENT_STATE is
  760.             when LOOKING_FOR_TOKEN  =>
  761.                if INLINE (I) > ' ' then
  762.                   CURRENT_STATE := IN_TOKEN;
  763.                   if INLINE (I) = '"' then
  764.                      QUOTED := TRUE;
  765.                      START  := I;
  766.                   else
  767.                      QUOTED := FALSE;
  768.                      START  := I;
  769.                   end if;
  770.                end if;
  771.             when IN_TOKEN =>
  772.                if QUOTED then
  773.                   if INLINE (I) = '"' then
  774.                      STOP          := I;
  775.                      STRING_LIST.ADD_TO_LIST (INLINE (START .. STOP));
  776.                      CURRENT_STATE := LOOKING_FOR_TOKEN;
  777.                   end if;
  778.                elsif INLINE (I) <= ' ' then
  779.                   STOP          := I - 1;
  780.                   STRING_LIST.ADD_TO_LIST (INLINE (START .. STOP));
  781.                   CURRENT_STATE := LOOKING_FOR_TOKEN;
  782.                end if;
  783.          end case;
  784.       end loop;
  785.       if CURRENT_STATE = IN_TOKEN then
  786.          STOP := INLEN;
  787.          STRING_LIST.ADD_TO_LIST (INLINE (START .. STOP));
  788.       end if;
  789.       LOCAL_ARGC := STRING_LIST.NUMBER_OF_STRINGS;
  790.    end INITIALIZE;
  791.    
  792.    function ARGC return NATURAL is
  793.       
  794.       --========================= PDL ===========================
  795.       --|ABSTRACT:
  796.       --|    ARGC returns the argument count.
  797.       --|DESIGN DESCRIPTION:
  798.       --|    Return LOCAL_ARGC
  799.       --=========================================================
  800.       
  801.    begin
  802.       return LOCAL_ARGC;
  803.    end ARGC;
  804.  
  805.    function ARGV (INDEX : in NATURAL) return STRING is
  806.       
  807.       --========================= PDL ===========================
  808.       --|ABSTRACT:
  809.       --|    ARGV returns the indicated argument string.
  810.       --|DESIGN DESCRIPTION:
  811.       --|    If INDEX is out of range, raise INVALID_INDEX
  812.       --|    Return GET_FROM_LIST(INDEX)
  813.       --=========================================================
  814.       
  815.    begin
  816.       if INDEX >= LOCAL_ARGC then
  817.          raise INVALID_INDEX;
  818.       end if;
  819.       return STRING_LIST.GET_FROM_LIST (INDEX);
  820.    exception
  821.       when INVALID_INDEX  =>
  822.          raise ;
  823.       when others    =>
  824.          raise UNEXPECTED_ERROR;
  825.    end ARGV;
  826.    
  827. end CLI;
  828. --::::::::::
  829. --climerdn.ada
  830. --::::::::::
  831. -- ****************************************
  832. -- *                                      *
  833. -- * CLI (Command Line Interface)         * BODY
  834. -- *  for Meridian Ada, Version 3.x       *
  835. -- *  requires AdaVantage Utility Library *
  836. -- *                                      *
  837. -- ****************************************
  838. with ARG;  -- from AdaVantage Utility Library
  839. package body CLI is
  840.  
  841.   NAME_OF_PROGRAM : STRING(1..100);
  842.   NAME_OF_PROGRAM_LAST : NATURAL := 0;
  843.  
  844.   -- ...................................
  845.   -- .                                 .
  846.   -- . INITIALIZE                      . BODY
  847.   -- .                                 .
  848.   -- ...................................
  849.   procedure INITIALIZE (PROGRAM_NAME        : in STRING;
  850.                         COMMAND_LINE_PROMPT : in STRING) is
  851.   begin
  852.     NAME_OF_PROGRAM(1..PROGRAM_NAME'LENGTH) := PROGRAM_NAME;
  853.     NAME_OF_PROGRAM_LAST := PROGRAM_NAME'LENGTH;
  854.   exception
  855.     when others => raise UNEXPECTED_ERROR;
  856.   end INITIALIZE;
  857.  
  858.   -- ...................................
  859.   -- .                                 .
  860.   -- . ARGC (Argument Count)           . BODY
  861.   -- .                                 .
  862.   -- ...................................
  863.   function ARGC return NATURAL is
  864.   begin
  865.     return ARG.COUNT;
  866.   exception
  867.     when others => raise UNEXPECTED_ERROR;
  868.   end ARGC;
  869.  
  870.   -- ...................................
  871.   -- .                                 .
  872.   -- . ARGV (Argument Value)           . BODY
  873.   -- .                                 .
  874.   -- ...................................
  875.   function ARGV (INDEX : in NATURAL) return STRING is
  876.   begin
  877.     if INDEX = 0 then
  878.       return NAME_OF_PROGRAM(1..NAME_OF_PROGRAM_LAST);
  879.     else
  880.       if INDEX >= ARGC then
  881.         raise INVALID_INDEX;
  882.       else
  883.         return ARG.DATA(POSITIVE(INDEX+1));
  884.       end if;
  885.     end if;
  886.   exception
  887.     when INVALID_INDEX => raise;
  888.     when others => raise UNEXPECTED_ERROR;
  889.   end ARGV;
  890.  
  891. end CLI;
  892. --::::::::::
  893. --cliverdx.ada
  894. --::::::::::
  895. -- This implementation of Package Body CLI is Verdix-specific (SUN).
  896. -- The following Verdix Ada packages must be compiled into
  897. -- the Ada library or an Ada program unit library containing these
  898. -- packages must be placed in the library search path before this
  899. -- package body is compiled:
  900. --      standard/a_strings.a
  901. --      standard/a_strings_b.a
  902. --      standard/c_strings.a
  903. --      standard/c_strings_b.a
  904. --      verdixlib/cmd_line_s.a
  905. --      verdixlib/cmd_line_b.a
  906. -- Verdix Ada Development System, Version 5.41 and 5.5
  907. with COMMAND_LINE;
  908. with A_STRINGS;
  909. package body CLI is
  910.  
  911.    LOCAL_ARGC : NATURAL := NATURAL (COMMAND_LINE.ARGC);
  912.    -- Local value of ARGC stored internally
  913.  
  914.    procedure INITIALIZE (PROGRAM_NAME        : in STRING;
  915.                          COMMAND_LINE_PROMPT : in STRING) is
  916.       
  917.       --========================= PDL ===========================
  918.       --|ABSTRACT:
  919.       --|    INITIALIZE prompts the user for the command line
  920.       --|    arguments and loads the linked list with them.
  921.       --|DESIGN DESCRIPTION:
  922.       --|    Do nothing (no initialization required)
  923.       --=========================================================
  924.       
  925.    begin
  926.       null;
  927.    end INITIALIZE;
  928.    
  929.    function ARGC return NATURAL is
  930.       
  931.       --========================= PDL ===========================
  932.       --|ABSTRACT:
  933.       --|    ARGC returns the argument count.
  934.       --|DESIGN DESCRIPTION:
  935.       --|    Return LOCAL_ARGC
  936.       --=========================================================
  937.       
  938.    begin
  939.       return LOCAL_ARGC;
  940.    end ARGC;
  941.  
  942.    function ARGV (INDEX : in NATURAL) return STRING is
  943.       
  944.       --========================= PDL ===========================
  945.       --|ABSTRACT:
  946.       --|    ARGV returns the indicated argument string.
  947.       --|DESIGN DESCRIPTION:
  948.       --|    If INDEX is out of range, raise INVALID_INDEX
  949.       --|    Return COMMAND_LINE.ARGV.all (INTEGER (INDEX)).all.S
  950.       --=========================================================
  951.       
  952.    begin
  953.       if INDEX >= LOCAL_ARGC then
  954.          raise INVALID_INDEX;
  955.       end if;
  956.       return COMMAND_LINE.ARGV.all (INTEGER (INDEX)).all.S;
  957.    exception
  958.       when INVALID_INDEX  =>
  959.          raise ;
  960.       when others    =>
  961.          raise UNEXPECTED_ERROR;
  962.    end ARGV;
  963.    
  964. end CLI;
  965. --::::::::::
  966. --clivms.ada
  967. --::::::::::
  968. -- This implementation of Package Body CLI is for DEC Ada using VAX/VMS.
  969. -- It has been tested under VAX/VMS 4.5 using DEC Ada Version 1.3-24.
  970. -- Note: any executable produced which uses this package must be able to
  971. -- read the command line parameters.  To do this, after producing the EXE
  972. -- file via ACS LINK, you have to define a symbol like:
  973. --    $ symbol:==$disk:[dir]exe-file-name
  974. -- and then run the program by using the symbol:
  975. --    $ symbol this is a test
  976. package body CLI is
  977.  
  978.    LOCAL_ARGC : NATURAL := 1;
  979.    -- Local ARGC value stored internally
  980.  
  981.    package STRING_LIST is
  982.       
  983.       NUMBER_OF_STRINGS : NATURAL := 0;
  984.       
  985.       procedure ADD_TO_LIST (ITEM : in STRING);
  986.       function GET_FROM_LIST (ITEM : in NATURAL) return STRING;
  987.       
  988.    end STRING_LIST;
  989.    
  990.    package body STRING_LIST is
  991.       
  992.       type DYNAMIC_STRING_OBJECT (LENGTH : NATURAL);
  993.       type DYNAMIC_STRING is access DYNAMIC_STRING_OBJECT;
  994.       type DYNAMIC_STRING_OBJECT (LENGTH : NATURAL) is 
  995.          record
  996.             DS   : STRING (1 .. LENGTH);
  997.             NEXT : DYNAMIC_STRING;
  998.          end record;
  999.       
  1000.       FIRST : DYNAMIC_STRING := null;
  1001.       LAST  : DYNAMIC_STRING := null;
  1002.       
  1003.       procedure ADD_TO_LIST (ITEM : in STRING) is
  1004.          
  1005.          --========================= PDL ===========================
  1006.          --|ABSTRACT:
  1007.          --|    ADD_TO_LIST adds the ITEM string to the linked list
  1008.          --|    of dynamic strings implemented by this package.
  1009.          --|DESIGN DESCRIPTION:
  1010.          --|    Create new DYNAMIC_STRING_OBJECT of the proper length
  1011.          --|    Set DS field of new object to the ITEM string
  1012.          --|    Set the NEXT field of the new object to NULL
  1013.          --|    If FIRST pointer is null
  1014.          --|      Set FIRST and LAST to point to the new object
  1015.          --|    Else
  1016.          --|      Set LAST.NEXT to point to the new object
  1017.          --|      Set LAST to point to the new object
  1018.          --|    End if
  1019.          --|    Increment NUMBER_OF_STRINGS
  1020.          --=========================================================
  1021.          
  1022.          TEMP : DYNAMIC_STRING;
  1023.       begin
  1024.          TEMP := new DYNAMIC_STRING_OBJECT (ITEM'LENGTH);
  1025.          TEMP.DS (1 .. ITEM'LENGTH) := ITEM;
  1026.          TEMP.NEXT                  := null;
  1027.          if FIRST = null then
  1028.             FIRST := TEMP;
  1029.             LAST  := TEMP;
  1030.          else
  1031.             LAST.NEXT := TEMP;
  1032.             LAST      := TEMP;
  1033.          end if;
  1034.          NUMBER_OF_STRINGS := NUMBER_OF_STRINGS + 1;
  1035.       end ADD_TO_LIST;
  1036.       
  1037.       function GET_FROM_LIST (ITEM : in NATURAL) return STRING is
  1038.          
  1039.          --========================= PDL ===========================
  1040.          --|ABSTRACT:
  1041.          --|    GET_FROM_LIST returns the ITEM string from the linked list
  1042.          --|    of dynamic strings implemented by this package.
  1043.          --|DESIGN DESCRIPTION:
  1044.          --|    If ITEM > 0
  1045.          --|        Advance to desired item
  1046.          --|    End If
  1047.          --|    Return the DS field of the desired item
  1048.          --=========================================================
  1049.          
  1050.          ROVER : DYNAMIC_STRING := FIRST;
  1051.       begin
  1052.          if ITEM > 0 then
  1053.             for I in 1 .. ITEM loop
  1054.                ROVER := ROVER.NEXT;
  1055.             end loop;
  1056.          end if;
  1057.          return ROVER.DS;
  1058.       end GET_FROM_LIST;
  1059.       
  1060.    end STRING_LIST;
  1061.    
  1062.    procedure INITIALIZE (PROGRAM_NAME        : in STRING;
  1063.                          COMMAND_LINE_PROMPT : in STRING) is
  1064.       
  1065.       --========================= PDL ===========================
  1066.       --|ABSTRACT:
  1067.       --|    INITIALIZE prompts the user for the command line
  1068.       --|    arguments and loads the linked list with them.
  1069.       --|DESIGN DESCRIPTION:
  1070.       --|    Set CURRENT_STATE to LOOKING_FOR_TOKEN
  1071.       --|    Set PROGRAM_NAME as first token
  1072.       --|    Obtain the command line string from VAX/VMS
  1073.       --|    Over number of characters in line, loop
  1074.       --|        Case CURRENT_STATE
  1075.       --|            When LOOKING_FOR_TOKEN
  1076.       --|                If character is not white-space
  1077.       --|                    Set CURRENT_STATE to IN_TOKEN
  1078.       --|                    If character is quote (")
  1079.       --|                        Set QUOTED to TRUE
  1080.       --|                        Set START to the character's index + 1
  1081.       --|                    Else
  1082.       --|                        Set QUOTED to FALSE
  1083.       --|                        Set START to the character's index
  1084.       --|                    End IF
  1085.       --|                End If
  1086.       --|            When IN_TOKEN
  1087.       --|                If QUOTED
  1088.       --|                    If character is quote (")
  1089.       --|                        Set STOP to the previous character's index
  1090.       --|                        Add slice from START to STOP to list
  1091.       --|                        Set CURRENT_STATE to LOOKING_FOR_TOKEN
  1092.       --|                    End If
  1093.       --|                ElsIF character is white-space
  1094.       --|                    Set STOP to the previous character's index
  1095.       --|                    Add slice from START to STOP to list
  1096.       --|                    Set CURRENT_STATE to LOOKING_FOR_TOKEN
  1097.       --|                End If
  1098.       --|        End Case
  1099.       --|    End Loop
  1100.       --|    If CURRENT_STATE is IN_TOKEN
  1101.       --|        Set STOP to the previous character's index
  1102.       --|        Add slice from START to STOP to list
  1103.       --|    End if
  1104.       --|    Set LOCAL_ARGC to NUMBER_OF_STRINGS
  1105.       --=========================================================
  1106.       
  1107.       ARGCOUNT      : NATURAL := 1;
  1108.       INLINE        : STRING (1 .. 132); -- for VAX/VMS
  1109.       START         : NATURAL;
  1110.       STOP          : NATURAL;
  1111.       QUOTED        : BOOLEAN;
  1112.  
  1113.       type STATE is (LOOKING_FOR_TOKEN, IN_TOKEN);
  1114.       CURRENT_STATE : STATE   := LOOKING_FOR_TOKEN;
  1115.  
  1116.       -- Get command line from VAX/VMS
  1117.       procedure GET_FOREIGN (LINE : out STRING);
  1118.       pragma INTERFACE (EXTERNAL, GET_FOREIGN);
  1119.       pragma IMPORT_VALUED_PROCEDURE (GET_FOREIGN,
  1120.                                       "LIB$GET_FOREIGN",
  1121.                                       (STRING),
  1122.                                       (DESCRIPTOR(S)));
  1123.  
  1124.    begin
  1125.       STRING_LIST.ADD_TO_LIST (PROGRAM_NAME);
  1126.       GET_FOREIGN (INLINE); -- INLINE is command line from VAX/VMS
  1127.       for I in INLINE'RANGE loop
  1128.          case CURRENT_STATE is
  1129.             when LOOKING_FOR_TOKEN  =>
  1130.                if INLINE (I) > ' ' then
  1131.                   CURRENT_STATE := IN_TOKEN;
  1132.                   if INLINE (I) = '"' then
  1133.                      QUOTED := TRUE;
  1134.                      START  := I;
  1135.                   else
  1136.                      QUOTED := FALSE;
  1137.                      START  := I;
  1138.                   end if;
  1139.                end if;
  1140.             when IN_TOKEN =>
  1141.                if QUOTED then
  1142.                   if INLINE (I) = '"' then
  1143.                      STOP          := I;
  1144.                      STRING_LIST.ADD_TO_LIST (INLINE (START .. STOP));
  1145.                      CURRENT_STATE := LOOKING_FOR_TOKEN;
  1146.                   end if;
  1147.                elsif INLINE (I) <= ' ' then
  1148.                   STOP          := I - 1;
  1149.                   STRING_LIST.ADD_TO_LIST (INLINE (START .. STOP));
  1150.                   CURRENT_STATE := LOOKING_FOR_TOKEN;
  1151.                end if;
  1152.          end case;
  1153.       end loop;
  1154.       if CURRENT_STATE = IN_TOKEN then
  1155.          STOP := INLINE'LAST;
  1156.          STRING_LIST.ADD_TO_LIST (INLINE (START .. STOP));
  1157.       end if;
  1158.       LOCAL_ARGC := STRING_LIST.NUMBER_OF_STRINGS;
  1159.    end INITIALIZE;
  1160.    
  1161.    function ARGC return NATURAL is
  1162.       
  1163.       --========================= PDL ===========================
  1164.       --|ABSTRACT:
  1165.       --|    ARGC returns the argument count.
  1166.       --|DESIGN DESCRIPTION:
  1167.       --|    Return LOCAL_ARGC
  1168.       --=========================================================
  1169.       
  1170.    begin
  1171.       return LOCAL_ARGC;
  1172.    end ARGC;
  1173.  
  1174.    function ARGV (INDEX : in NATURAL) return STRING is
  1175.       
  1176.       --========================= PDL ===========================
  1177.       --|ABSTRACT:
  1178.       --|    ARGV returns the indicated argument string.
  1179.       --|DESIGN DESCRIPTION:
  1180.       --|    If INDEX is out of range, raise INVALID_INDEX
  1181.       --|    Return GET_FROM_LIST(INDEX)
  1182.       --=========================================================
  1183.       
  1184.    begin
  1185.       if INDEX >= LOCAL_ARGC then
  1186.          raise INVALID_INDEX;
  1187.       end if;
  1188.       return STRING_LIST.GET_FROM_LIST (INDEX);
  1189.    exception
  1190.       when INVALID_INDEX  =>
  1191.          raise ;
  1192.       when others    =>
  1193.          raise UNEXPECTED_ERROR;
  1194.    end ARGV;
  1195.    
  1196. end CLI;
  1197.